<template>
    <van-dialog
        title="提示"
        v-model="showDialog"
        :before-close="beforeClose"
        >
        <van-cell-group>
            <van-field
                value="9527"
                label="校验码"
                left-icon="contact"
                disabled
            />
            <van-field
                v-model="code"
                left-icon="records"
                label="校验码"
                placeholder="请输入校验码"
            />
        </van-cell-group>
        
    </van-dialog>
</template>
<script>
export default {
    name:'my-dialog',
    data(){
        return {
            showDialog:false,
            code:'',
            call:null
        }
    },
    methods:{
        show(call){
            // call && call()
            this.call = call;
            this.showDialog = true;
        },
        beforeClose(action,done){
            console.log(action);
            if(this.code !== '9527'){
                this.$toast('请输入正确的验证码')
                done(false);
                return;
            }
            setTimeout(() =>{
                done()
                if(this.call){
                    this.call();
                }
            }, 1000);
        }
    }
}
</script>
